<template>
  <div class="createPost-container">
    <el-form ref="postForm" :model="MessageDetailForm" :rules="rules"  class="form-container">
      <div class="createPost-main-container">
        <el-row>
          <el-col :span="24">
            <el-form-item style="margin-bottom: 20px;"  label="Id:"> : {{MessageDetailForm.id}} </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item style="margin-bottom: 20px;"  label="用户Id:"> : {{MessageDetailForm.uid}} </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item style="margin-bottom: 20px;"  label="标题:"> {{MessageDetailForm.title}} </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item style="margin-bottom: 20px;" label="内容:" >  {{MessageDetailForm.content}} </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="status:" >  {{MessageDetailForm.status}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="type:" > {{MessageDetailForm.type}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="isread:" >  {{MessageDetailForm.isread}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="createdt:" >  {{MessageDetailForm.createdt}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="readtime:" >  {{MessageDetailForm.readtime}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="cid:" >  {{MessageDetailForm.cid}} </el-form-item>
        </el-row>

        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="sourceId:" >  {{MessageDetailForm.sourceId}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="控制器Id:" >  {{MessageDetailForm.controlId}} </el-form-item>
        </el-row>
        <el-row>
          <el-form-item style="margin-bottom: 20px;" label="创建时间:" >  {{MessageDetailForm.createdt}} </el-form-item>
        </el-row>
      </div>
    </el-form>
  </div>
</template>

<script>
import { MessageDetail } from '@/api/Message'
import { userSearch } from '@/api/remoteSearch'

const defaultForm = {
  id:'',
  controlId: '',
  MessageId: '',
  customerId: '',
  MessageKey: '',
  value1: '',
  value2: '',
  value3: '',
  value4: '',
  value5: '',
  value6: '',
  status: 1,
  createTime: '',
  type: ''
}

export default {
  name: 'messagedetail',
  components: {   },
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      MessageDetailForm: Object.assign({}, defaultForm),
      loading: false,
      userListOptions: [],
      rules: {

      }
    }
  },
  computed: {
    contentShortLength() {
      return this.MessageDetailForm.content_short.length
    }
  },
  created() {
    if (this.isEdit) {
      const id = this.$route.query && this.$route.query.id
      this.fetchData(id)
    } else {
      this.MessageDetailForm = Object.assign({}, defaultForm)
    }
  },
  methods: {
    fetchData(id) {
      MessageDetail({ id: id }).then(response => {
        this.MessageDetailForm = response.data.data
        console.log(this.MessageDetailForm)
      }).catch(err => {
        console.log(err)
      })
    },
    getRemoteUserList(query) {
      userSearch(query).then(response => {
        if (!response.data.items) return
        this.userListOptions = response.data.items.map(v => v.name)
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.createPost-container {
  position: relative;
  .createPost-main-container {
    padding: 40px 45px 20px 50px;
    .postInfo-container {
      position: relative;
      @include clearfix;
      margin-bottom: 10px;
      .postInfo-container-item {
        float: left;
      }
    }
    .editor-container {
      min-height: 500px;
      margin: 0 0 30px;
      .editor-upload-btn-container {
        text-align: right;
        margin-right: 10px;
        .editor-upload-btn {
          display: inline-block;
        }
      }
    }
  }
  .word-counter {
    width: 40px;
    position: absolute;
    right: -10px;
    top: 0px;
  }
}
</style>
